﻿<%
class ActionForeach
	public sub index
		Mo.Assign "title","each/foreach演示"
		Mo.display "home:top"
		F.echo "<h3>遍历可枚举变量：</h3>"
		dim dict:set dict = F.activex("scripting.dictionary")
		
		'声明一个回调函数
		dim delgate:set delgate = F.lambda("(q, v)=>F.echo(q + ' = ' +v,true)")
		dim delgatewithstate:set delgatewithstate = F.lambda("(q, v, state)=>{F.echo(q + ' = ' +v,true);state.i++;}")
		
		dict("name")="moaspenginer"
		dict("age")=1
		dict("location")="杭州"
		F.each dict, F.lambda("q","src","F.echo(q + ' = ' + src(q),true)")
		
		F.echo "<h3>遍历get变量：</h3>"
		dim state:set state = F.json("{i:0}")
		F.foreach F.get__, delgatewithstate, state
		F.echo "共有[" & state.i & "]个GET项。"
		
		F.echo "<h3>遍历post变量：</h3>"
		F.post "name","moaspenginer" '因为是get方式访问的，这里设置一项post
		F.foreach F.post__, delgate
		
		F.echo "<h3>遍历server变量：</h3>"
		F.foreach F.server__, delgate
		Mo.display "home:foot"
	end sub
end class
%>